package yja.gzw.app.adapter

import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import yja.gzw.app.R
import yja.gzw.app.activity.HaoyouzhuyeActivity
import yja.gzw.app.activity.ZhquxActivity
import yja.gzw.app.model.bean.OrderData
import yja.gzw.app.model.bean.QueryItem

class ZhuanquAdapter (private val context: Context, private val list: List<OrderData>): RecyclerView.Adapter<RecyclerView.ViewHolder>(){
    private var view: View?=null
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        view= LayoutInflater.from(parent.context).inflate(R.layout.item_view_zhuanqu,parent,false)
        Log.e("图片地址展示","走到了2")
        return ViewHodeView(view!!)
    }

    override fun getItemCount(): Int {
        return  list.size
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        if(holder is ViewHodeView){
            holder.zhuanqu.text=list[position].title
            holder.cishu.text=list[position].release_num.toString()
            holder.fabupingtai.text=list[position].platform_id.toString()
            holder.biaoti.text=list[position].label


            holder.itemView.setOnClickListener {
                val intent = Intent(context,ZhquxActivity::class.java)

                intent.putExtra("id",list[position].id.toString())
                intent.putExtra("youid",list[position].user_id.toString())
                context.startActivity(intent)


            }
        }


    }



    inner class ViewHodeView(itemView: View):RecyclerView.ViewHolder(itemView){
        val zhuanqu: TextView =itemView.findViewById(R.id.zhuanquname)
        val cishu: TextView =itemView.findViewById(R.id.cishu)
        val fabupingtai: TextView =itemView.findViewById(R.id.fabupingtai)
        val biaoti: TextView =itemView.findViewById(R.id.biaoti)
        val tupian: ImageView =itemView.findViewById(R.id.tupian)
    }
}